import type {
  ElButton,
  ElInput,
  ElRadioGroup,
  ElSwitch,
  ElSelect,
  ElDatePicker,
  ElInputNumber,
  ElTreeSelect,
  ElUpload,
} from 'element-plus';

interface ComponentPropsMap {
  input: Partial<InstanceType<typeof ElInput>> & {
    prepend?: string;
    append?: string;

    rightText?:string; //右侧input文字描述
    textLmargin?:string;
    placeholder?: string;
    width?: any;
  };
  textarea: Partial<InstanceType<typeof ElInput>> & {
    prepend?: string;
    append?: string;
    width?: string;
  };
  input2: Partial<InstanceType<typeof ElInput>> & {
    prepend?: string;
    append?: string;
    placeholder?: string;
    width?: string;
    props?: any;
    width2?: string;
    prompt?: string;
  };
  slotName: any;
  text:any;
  number: Partial<InstanceType<typeof ElInputNumber>> & {
    width?: string;
  };
  button: Partial<InstanceType<typeof ElButton>>;
  radioGroup: Partial<InstanceType<typeof ElRadioGroup>>;
  switch: Partial<InstanceType<typeof ElSwitch>>;
  select: Partial<InstanceType<typeof ElSelect>>& {
    prepend?: string;
    append?: string;
    placeholder?: string;
    width?: any;
    customize?: boolean;
  };
  upload: Partial<InstanceType<typeof ElUpload>>;
  imgUpload: Partial<InstanceType<typeof ElUpload>>;
  avatarUpload: Partial<InstanceType<typeof ElUpload>>;
  content:any;
  password:any;
  cascader: any; // 省市县级联选择器
  treeSelect: Partial<InstanceType<typeof ElTreeSelect>>;
  date: Partial<InstanceType<typeof ElDatePicker>> & {
    width?: string;
  };
  time: Partial<InstanceType<typeof ElDatePicker>> & {
    width?: string;
  };
  daterange: Partial<InstanceType<typeof ElDatePicker>> & {
    width?: string;
  };
  slot: any;
}

type RadioGroupOption = {
  label: string;
  value: string | number | boolean;
};
type TreeSelectList = {
  label: string;
  value: string | number;
  children: TreeSelectList[];
};
type selectGroupOptions = {
  label: string;
  value: string | number | boolean;
};
type switchProps = Partial<InstanceType<typeof ElSwitch>> & {
  onChange: (row: any) => void;
};
type PageFormItem = {
  [T in keyof ComponentPropsMap]: {
    handleExceed?:any;
    labelWidth?:string;
    onSelect?: any;
    onInput?: any;
    onChange?: any; // 级联选择器变化回调
    addressProp?: string; // 关联的地址字段名
    span: number;
    label: string;
    labelR?:string;  //选择器右侧文字
    labelRNum?:any;  //选择器右侧距离
    labelLNum?:any;  //选择器左侧距离
    prop: string;
    max?: number;
    min?: number;
    width?: any;
    disabled?: boolean;
    component: T;
    active?: boolean | string;
    inactive?: boolean | string;
    multiple?: boolean;
    checkbox?: boolean;
    hidden?: ComputedRef<boolean> | boolean | undefined;
    switchProps?: switchProps;
    beforeUpload?: any;
    onSuccess?: any;
    treeSelectList?: TreeSelectList[];
    cascaderOptions?: any[]; // 级联选择器数据
    cascaderProps?: any; // 级联选择器配置
    componentProps?: ComponentPropsMap[T];
    slotName?: any;
    radioGroupOptions?: RadioGroupOption[];
    selectGroupOptions?: selectGroupOptions[] | undefined;
  };
}[keyof ComponentPropsMap];

export type PageFormList = {
  list: PageFormItem[];
}[];

export type HaderFormList = any[];
